import xadmin
from xadmin import views

from apps.user.models import User, Address, AddressManager


#


class BaseSetting(object):
    enable_themes = True  # 打开主题功能
    use_bootswatch = True  #


# 针对全局的
class GlobalSettings(object):
    site_title = "天天生鲜后台管理系统"  # 系统名称
    site_footer = "天天生鲜"  # 底部版权栏
    # menu_style = "accordion"  # 将菜单栏收起来


# 注册，注意一个是BaseAdminView，一个是CommAdminView
xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSettings)


class AddressAdmin(object):
    list_display = ['user', 'receiver', 'addr', 'zip_code', 'phone', 'is_default', 'create_time', 'update_time',
                    'is_delete']
    search_fields = ['user', ]
    list_filter = ['user', 'receiver', 'addr', 'create_time']


xadmin.site.unregister(User)
xadmin.site.register(User)
xadmin.site.register(Address,AddressAdmin)